import { IncomingHttpHeaders } from 'http';

import op from '@dfeidao/atom-nodejs/db/operate';

import {  productid,systemid} from '../../atom/config';

interface Message {
	filter: {
		productid: string,
		knowledge_no: string,
		knowledge_name: string,
		knowledge_explain: string
	};
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string;
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const { exec,  update } = op(action_id, session_id, systemid);
	// 插入数据
	update('knowledge_base_2', { productid,knowledge_no:message.filter.knowledge_no}, {knowledge_name:message.filter.knowledge_name,
		knowledge_explain:message.filter.knowledge_explain });

	const ret = await exec();
	return ret;
}
